package cn.dust.design.pattern.behavioral.strategy;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: dust
 * @Date: 2019/11/27 19:30
 */
public class PromotionStrategyFactory {
    private static Map<String ,PromotionStrategy> Promotion_Strategy_MAP=new HashMap<String, PromotionStrategy>();
    static {
        Promotion_Strategy_MAP.put(PromotionKey.FANLI,new FanliPromotionStrategy());
        Promotion_Strategy_MAP.put(PromotionKey.MANJIAN,new ManjianPromotionStrategy());
        Promotion_Strategy_MAP.put(PromotionKey.FANXIAN,new FanxianPromotionStrategy());
    }

    private static final PromotionStrategy NON_Promotion_Strategy=new EmptyPromotionStrategy();

    private PromotionStrategyFactory(){}

    public static PromotionStrategy getPromotionStrategy(String key){
        PromotionStrategy promotionStrategy=Promotion_Strategy_MAP.get(key);

        return promotionStrategy==null?NON_Promotion_Strategy:promotionStrategy;
    }


    private interface PromotionKey{
        String FANLI="FANLI";
        String FANXIAN="FANXIAN";
        String MANJIAN="MANJIAN";
    }

}
